const pino = require('pino');

const level = process.env.LOG_LEVEL || 'info';

const logger = pino({
  level,
  transport: process.env.NODE_ENV !== 'production'
    ? { target: 'pino-pretty', options: { colorize: true } }
    : undefined
});

const httpLoggerStream = {
  write: (msg) => {
    logger.info(msg.trim());
  }
};

module.exports = {
  logger,
  httpLoggerStream
};
